/*
  学习目标：useEffect依赖项可以同时写多个
*/

import React, { useEffect, useState } from 'react';

export default function App() {
  const [count, setCount] = useState(0);
  const [msg, setMsg] = useState('');

  useEffect(() => {
    console.log('我被执行了  ----->  ');
    document.title = count + msg;
  }, [count, msg]); // 🔔[依赖项, 依赖项2,...] 多个依赖项，表示同时监听多个状态的变化

  return (
    <div>
      msg -- {msg}
      <hr />
      count -- {count}
      <hr />
      <button onClick={() => setMsg(msg + '~')}>点我修改msg</button>
      <button onClick={() => setCount(count + 1)}>点我修改count</button>
    </div>
  );
}
